﻿using UnityEngine;
using System.Collections;

public class PlayerScript : MonoBehaviour
{
	public float vel;

	void Start () 
	{
	
	}
	
	void Update ()
	{
		if(Input.GetKey(KeyCode.D))
		{
			transform.position += new Vector3(vel * Time.deltaTime, 0, 0); 	
		}

		if(Input.GetKey(KeyCode.A))
		{
			transform.position += new Vector3(-vel * Time.deltaTime, 0, 0); 	
		}

		if(Input.GetKey(KeyCode.W))
		{
			transform.position += new Vector3(0, vel * Time.deltaTime, 0); 	
		}

		if(Input.GetKey(KeyCode.S))
		{
			transform.position += new Vector3(0, -vel * Time.deltaTime, 0); 	
		}

		if(transform.position.x > 8f)
		{
			transform.position = new Vector3(8f, transform.position.y, 0);
		}
		if(transform.position.x < -8f)
		{
			transform.position = new Vector3(-8f, transform.position.y, 0);
		}
		if(transform.position.y > 2.9f)
		{
			transform.position = new Vector3(transform.position.x, 2.1f, 0);
		}
		if(transform.position.y <0 -4.5f)
		{ 
			transform.position = new Vector3(transform.position.x, -4.5f, 0);
		}


	}

	void OnTriggerEnter2D(Collider2D other)
	{
		Debug.Log (other.gameObject.tag);

	}
}